using System;

namespace NFreeMarker.Core
{
    /**
     * Represents a &lt;break&gt; instruction to break out of a loop.
     * @author <A HREF="mailto:jon@revusky.com">Jonathan Revusky</A>
     */
    public sealed class BreakInstruction : TemplateElement // NOTE: Was internal
    {
        internal override void Accept(Environment env)
        {
            throw Break.Instance;
        }

        public override string GetCanonicalForm()
        {
            return "<#break/>";
        }

        public override string GetDescription()
        {
            return "break" + " [" + GetStartLocation() + "]";
        }

        internal class Break : ApplicationException
        {
            public static readonly Break Instance = new Break();
        }
    }
}